home *** CD-ROM | disk | FTP | other *** search
- #include "barchart.h"
-
- struct EventRecord myEvent;
- struct GrafPort *whichWindow;
-
- handleevents()
- {
- int code;
-
- for (;;) {
- SystemTask();
- if (!GetNextEvent(everyEvent, &myEvent))
- continue;
- switch(myEvent.what) {
- case mouseDown:
- code = FindWindow(&myEvent.where, &whichWindow);
- switch (code) {
- case inMenuBar:
- docommand(MenuSelect(&myEvent.where));
- break;
- case inSysWindow:
- SystemClick(&myEvent, whichWindow);
- break;
- case inDrag:
- DragWindow(whichWindow, &myEvent.where, &dragRect);
- break;
- case inGrow:
- dogrow(whichWindow);
- break;
- case inContent:
- if (whichWindow != FrontWindow())
- SelectWindow(whichWindow);
- else {
- }
- break;
- case inGoAway:
- DisposeWindow(myWindow);
- return;
- }
- break;
-
- case keyDown:
- case autoKey:
- break;
- case activateEvt:
- SetPort(myWindow);
- break;
-
- case updateEvt:
- SetPort(myWindow);
- BeginUpdate(myWindow);
- EraseRect(&myWindow->portRect);
- redraw();
- EndUpdate(myWindow);
- break;
- }
- }
- }
-
- docommand(mResult)
- long mResult;
- {
- int theItem, theMenu;
- char name[40];
-
- theMenu = mResult >> 16;
- theItem = mResult;
- if (theMenu == appleMenu) {
- GetItem(myMenus[0], theItem, name);
- OpenDeskAcc(name);
- }
- HiliteMenu(0);
- }
-
- #define ScreenWidth 512
- #define ScreenHeight 342
- #define MenuBarHeight 20
- #define MinWidth 80
- #define MinHeight 80
- #define SBarWidth 16
-
- dogrow(whichWindow)
- WindowPtr whichWindow;
- {
- Rect sizeRect;
- long newSize;
- int newWidth, newHeight;
-
- if (whichWindow != FrontWindow())
- SelectWindow(whichWindow);
- else {
- SetRect(&sizeRect, MinWidth, MinHeight, ScreenWidth,
- ScreenHeight - MenuBarHeight);
- newSize = GrowWindow(whichWindow,&myEvent.where,&sizeRect);
-
- if (newSize) {
- EraseRect(&whichWindow->portRect);
- newWidth = newSize & 0xffff;
- newHeight = (newSize>>16) & 0xffff;
- SizeWindow(whichWindow, newWidth, newHeight, TRUE);
- InvalRect(&whichWindow->portRect);
- redraw();
- }
- }
- }
-